package com.sunwayhorizo.health.hl7.rim;

import com.sunwayhorizo.health.hl7.common.DataTypeUtil;
import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.datatypes.CE;
import com.sunwayhorizo.health.hl7.persistent.RimCoreActCdSets;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQuery;

import static com.sunwayhorizo.health.hl7.vocabulary.ActCdSetCode.*;


@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("PROC")
@NamedQuery(name = "Procedure.findAll", query = "select o from Procedure o")
public class Procedure extends Act implements Serializable {
	protected static final long serialVersionUID = 1L;
    
/*    public SET_CE ApproachSiteCode;
    public SET_CE MethodCode;
    public SET_CE TargetSiteCode;
*/    
    public Procedure() throws Hl7Exception {
    }
    

    public void setApproachSiteCode(CE ApproachSiteCode) 
    {
      CE ce = ApproachSiteCode; 	 
   	  if(null != ce && ce.codeSystemEnName()!=null && ce.codeName()!= null)
        {
   	       setRimCoreActCdSets(ce, PRAPPROACHSITECDSETCODE);
        }
        else
        {
            this.setPrApproachSiteCodeEtsId(ce.code().toString());
        }
    }

    public CE getApproachSiteCode() throws Hl7Exception
    {
    	if (this.getPrApproachSiteCodeEtsId().equals(PRAPPROACHSITECDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPrApproachSiteCodeEtsId().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets); 
                }
            }             
        }
        else
            return DataTypeUtil.getCE(this.getPrApproachSiteCodeEtsId());  
   	 return null;
    }

    public void setMethodCode(CE MethodCode) 
    {
    	 CE ce = MethodCode;   	 
      	 if(null != ce && ce.codeSystemEnName()!=null && ce.codeName()!= null)
           {
      	     setRimCoreActCdSets(ce, PRMETHODCDSETCODE);
           }
           else
           {
               this.setPrMethodCodeEtsId(ce.code().toString());
           }
    }

    public CE getMethodCode() throws Hl7Exception
    {
    	if (this.getPrMethodCodeEtsId().equals(PRMETHODCDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPrMethodCodeEtsId().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets); 
                }
            }             
        }
        else
            return DataTypeUtil.getCE(this.getPrMethodCodeEtsId());  
   	 return null;
    }

    public void setTargetSiteCode(CE TargetSiteCode) 
    {
    	 CE ce = TargetSiteCode;    	 
     	 if(null != ce && ce.codeSystemEnName()!=null && ce.codeName()!= null)
          {
     	    setRimCoreActCdSets(ce, PRTARGETSITECDSETCODE);
          }
          else
          {
              this.setPrTargetsiteCodeEtsId(ce.code().toString());
          }
    }

    public CE getTargetSiteCode() throws Hl7Exception
    {
    	if (this.getPrTargetsiteCodeEtsId().equals(PRTARGETSITECDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getPrTargetsiteCodeEtsId().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets); 
                }
            }             
        }
        else
            return DataTypeUtil.getCE(this.getPrTargetsiteCodeEtsId());  
   	 return null;
    }
    
    @Column(name = "PR_APPROACHSITE_CODE_ETS_ID")
    protected String prApproachSiteCodeEtsId = PRAPPROACHSITECDSETCODE.toString();
    @Column(name = "PR_METHOD_CODE_ETS_ID")
    protected String prMethodCodeEtsId = PRMETHODCDSETCODE.toString();
    @Column(name = "PR_TARGETSITE_CODE_ETS_ID")
    protected String prTargetsiteCodeEtsId = PRTARGETSITECDSETCODE.toString();
    
	protected String getPrApproachSiteCodeEtsId() {
		return prApproachSiteCodeEtsId;
	}

	protected void setPrApproachSiteCodeEtsId(String prApproachSiteCodeEtsId) {
		this.prApproachSiteCodeEtsId = prApproachSiteCodeEtsId;
	}

	protected String getPrMethodCodeEtsId() {
		return prMethodCodeEtsId;
	}

	protected void setPrMethodCodeEtsId(String prMethodCodeEtsId) {
		this.prMethodCodeEtsId = prMethodCodeEtsId;
	}

	protected String getPrTargetsiteCodeEtsId() {
		return prTargetsiteCodeEtsId;
	}

	protected void setPrTargetsiteCodeEtsId(String prTargetsiteCodeEtsId) {
		this.prTargetsiteCodeEtsId = prTargetsiteCodeEtsId;
	}
    

}
